# windows/linux--py2/3 均支持
import paramiko

hostname = '192.168.75.124'
port = 22  
username = 'moocos'  
password = ' '

trans = paramiko.Transport((hostname, port))
trans.connect(username=username, password=password)
sftp = paramiko.SFTPClient.from_transport(trans)

fromfile = './paramiko_cmd.py'
tofile = '/home/moocos/paramiko_cmd.py'

# 发送文件
sftp.put(localpath=fromfile, remotepath=tofile)
# 下载文件
# sftp.get(remotepath, localpath)
trans.close()